package com.yixin.hospital.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yixin.hospital.common.ApiResult;
import com.yixin.hospital.entity.domain.DrugFactory;
import com.yixin.hospital.entity.dto.req.drugfactory.DrugFactoryAddReqDTO;
import com.yixin.hospital.entity.dto.req.drugfactory.DrugFactoryEditReqDTO;
import com.yixin.hospital.service.DrugFactoryService;
import com.yixin.hospital.mapper.DrugFactoryMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author Administrator
* @description 针对表【drug_factory(药品生产厂家表)】的数据库操作Service实现
* @createDate 2024-05-13 14:47:49
*/
@Service
public class DrugFactoryServiceImpl extends ServiceImpl<DrugFactoryMapper, DrugFactory>
    implements DrugFactoryService{

    @Resource
    DrugFactoryService drugFactoryService;


    @Override
    public ApiResult<?> add(DrugFactoryAddReqDTO drugFactoryAddReqDTO, String userName) {
        DrugFactory drugFactory = new DrugFactory();
        drugFactory.setFactory(drugFactoryAddReqDTO.getFactory());
        drugFactory.setCreatedBy(userName);
        drugFactory.setUpdatedBy(userName);
        drugFactoryService.save(drugFactory);
        return ApiResult.success();
    }

    @Override
    public ApiResult<?> edit(DrugFactoryEditReqDTO drugFactoryEditReqDTO, String userName) {
        DrugFactory drugFactory = new DrugFactory();
        drugFactory.setId(drugFactoryEditReqDTO.getId());
        drugFactory.setFactory(drugFactoryEditReqDTO.getFactory());
        drugFactory.setUpdatedBy(userName);
        drugFactoryService.updateById(drugFactory);
        return ApiResult.success();
    }
}




